const express = require("express");
const router = express.Router();
const users_handler = require("../router_handler/users");
/**
 * 获取用户信息
 * 入参 header 里面的token 解析获取两个id
 * 查出用户表和team表
 * 返回 { user: {}, team: {} }
 */
// router.get("/gettoken", users_handler.getToken);
// 导入需要验证上传文件对象
const {
  reg_users_schema,
  reg_updateAvatar_schema,
  reg_getPlacard_schema,
} = require("../schema/users");
// 导入验证数据的中间件
const expressJoi = require("@escook/express-joi");
/**
 * 登录
 * 入参 邮箱
 * 更具邮箱获取userId teamId 生成token
 * 返回 {token: }
 */
router.post("/mylogin", expressJoi(reg_users_schema), users_handler.login);

// 生成团队代码
router.get("/getCode", users_handler.getCode);

// 生成海报
router.get(
  "/getPlacard",
  expressJoi(reg_getPlacard_schema),
  users_handler.getPlacard
);

// 修改用户头像
router.post(
  "/updateAvatar",
  expressJoi(reg_updateAvatar_schema),
  users_handler.updateAvatar
);

// 获取用户信息列表
router.get("/getUsersList", users_handler.getUsersList);

// 获取用户信息
router.get("/getUserInfo", users_handler.getUserInfo);

//获取用户点赞数和分数
router.get("/myInfo", users_handler.myInfo);

module.exports = router;
